% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/one-step.R
\name{mrp_onestep}
\alias{mrp_onestep}
\title{Fits and tidies MRP outputs in one step}
\usage{
mrp_onestep(
  .formula,
  .data,
  poststrat_tgt,
  area_var = "cd",
  count_var = "count",
  weight_var = NULL,
  add_on = NULL,
  dtplyr = TRUE,
  ...
)
}
\arguments{
\item{.formula}{Formula in \verb{binary y ~ (1|x1) + (1|x2)} form.}

\item{.data}{Individual-level dataset}

\item{poststrat_tgt}{The poststratification target. It must contain the column
\code{count}, which is treated as the number of \code{trials} in the binomial model.}

\item{area_var}{Character for the variable(s) that corresponds to the area to
aggregate to.}

\item{count_var}{A character string for the variable name for the population
count in the \code{poststrat_tgt} dataframe. This will be renamed as if it is
a trial count in the model. Defaults to \code{"count"}.}

\item{weight_var}{Character for the variable that corresponds to weights.}

\item{add_on}{Any area-level data to be merged with the output,
for example validation data}

\item{dtplyr}{Whether to use a data.table/dtplyr backend for processing for
slightly faster dataframe wrangling. Currently does not apply to anything within the function.}

\item{...}{Additional arguments to pass to the model fitting function, \code{fit_brms()}}
}
\description{
Fits and tidies MRP outputs in one step
}
\details{
Combines \code{fit_brms}, \code{poststrat_draws}, and \code{direct_est}. See \code{scatter_45}
for options on visualization
}
\examples{
\dontrun{
library(ccesMRPviz)
mrp_fit <- mrp_onestep(response ~ (1|educ) + (1|cd),
                       .data = cces_GA,
                       poststrat_tgt = acs_GA,
                       area_var = "cd",
                       count_var = "count",
                       weight_var = "weight_post",
                       add_on = elec_GA)

scatter_45(mrp_fit, clinton_vote, p_mrp_est,
           xlab = "Clinton Vote", ylab = "MRP Estimate")
}

}
